//
//  MyNewsTableViewCell.m
//  TravelFollowYourHeart
//
//  Created by ENERGY on 2017/12/20.
//  Copyright © 2017年 Lwx. All rights reserved.
//

#import "MyNewsTableViewCell.h"
#define border 10
#define titleH 20

@interface MyNewsTableViewCell()
//@property (nonatomic, strong)UILabel * numberLab;
@property (nonatomic, strong)UILabel * titleLab;
@property (nonatomic, strong)UILabel * dataLab;
@property (nonatomic, strong)UILabel * contentLab;
@property (nonatomic, strong)UIView * lineView;
@end

@implementation MyNewsTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self.contentView addSubview:self.dataLab];
        [self.contentView addSubview:self.titleLab];
        [self.contentView addSubview:self.contentLab];
        

        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = getColor(@"cccccc");
        [self.contentView addSubview:_lineView];
        
    }return self;
}

- (UILabel *)titleLab{
    if (!_titleLab) {
        int titleLabW = SCREEN_WIDTH - self.dataLab.width - 2 * border;
        _titleLab = [[UILabel alloc] init];
        _titleLab.frame = CGRectMake(border, self.dataLab.top, titleLabW, titleH);
        _titleLab.text = @"010.名字最多有多少个字限制回复";
        _titleLab.font = [UIFont systemFontOfSize:14.0];
//        _titleLab.backgroundColor = [UIColor orangeColor];
        _titleLab.textAlignment = NSTextAlignmentLeft;
    }return _titleLab;
}

- (UILabel *)dataLab{
    if (!_dataLab) {
        int dataLabW = 110;
        int dataLabX = SCREEN_WIDTH - dataLabW;
        _dataLab = [[UILabel alloc] init];
        _dataLab.frame = CGRectMake(dataLabX, border, dataLabW, titleH);
        _dataLab.text = @"2017-05-22  22:15:12";
        _dataLab.font = [UIFont systemFontOfSize:10.0];
        _dataLab.textColor = [UIColor grayColor];
        _dataLab.textAlignment = NSTextAlignmentCenter;
//        _dataLab.backgroundColor = [UIColor greenColor];
    }return _dataLab;
}

- (UILabel *)contentLab{
    if (!_contentLab) {
        _contentLab = [[UILabel alloc] init];
        _contentLab.frame = CGRectMake(border, self.titleLab.bottom + border, SCREEN_WIDTH - 2 * border, 40);
//        _contentLab.backgroundColor = [UIColor purpleColor];
        _contentLab.lineBreakMode = NSLineBreakByWordWrapping;
        _contentLab.numberOfLines = 0;
        _contentLab.font = DEF_FontSize_14;
        _contentLab.text = @"啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦";
    }return _contentLab;
}

- (void)layoutSubviews{
    [super layoutSubviews];

//    int titleLabW = SCREEN_WIDTH - self.dataLab.width - 2 * border;
//    int dataLabW = 110;
//    int dataLabX = SCREEN_WIDTH - dataLabW;
//    self.dataLab.frame = CGRectMake(dataLabX, border, dataLabW, titleH);
//    self.titleLab.frame = CGRectMake(border, self.dataLab.top, titleLabW, titleH);
//    if ([self.delegate heightForCell:self.contentLab.text]) {
//    _contentLab.frame = CGRectMake(border, self.titleLab.bottom + border, SCREEN_WIDTH - 2 * border, [self.delegate heightForCell:_contentLab.text]);
//    }
//    _contentLab.frame = CGRectMake(border, self.titleLab.bottom + border, SCREEN_WIDTH - 2 * border, 40);
    self.lineView.frame = CGRectMake(border, self.contentView.height - 1, SCREEN_WIDTH - border, 1);
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModelData:(MyNewsDataModel *)modelData{
    _modelData = modelData;
    self.titleLab.text = modelData.nickname;
    self.contentLab.text = modelData.content;
    self.dataLab.text = modelData.addtime;
}

@end
